package cn.edu.bcu.ls.controller;

import java.util.List;

import cn.edu.bcu.ls.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.edu.bcu.ls.serviceImpl.ArticleService;
import io.swagger.annotations.ApiOperation;

@RestController
public class ArticleController {
	
	@Autowired
	private ArticleService articleService;
	
	@ApiOperation(value = "根据cId,aId（可以不传）查询文章 Article")
	@GetMapping(value="Article")
	public List selectBycIdaId(ArticleParams articleParams) {
		List<Article> articles = articleService.selectBycIdaId(articleParams);
		System.out.print(articles);
		return articles;
	}


	@ApiOperation(value = "上传文章，传入你想要的传的值就行")
	@PostMapping(value="Article")
	public boolean insertOrder(Article article) {
		if (articleService.insert(article) >0) {
			return true;
		}else {
			return false;
		}
	}


	@ApiOperation(value="修改文章，传入id和想修改的值")
	@PutMapping(value="Article")
	public boolean order(Article article) {
		if (articleService.updateByPrimaryKeySelective(article) >0) {
			return true;
		}else {
			return false;
		}
	}
}
	
	
	
